home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / mc51bugs.zip / Q30501 < prev    next >
Text File  |  1988-07-21  |  1KB  |  48 lines

  1. Q30501 Incorrect Code for Function Call
  2. C Compiler
  3. 5.10
  4. MS-DOS
  5.  
  6. Summary:
  7.    The compiler will generate incorrect code for the call to the
  8. function strcpy in the example below. The compiler is trying to use
  9. the association
  10.  
  11. macronames[nmacros]=macropointer=macrobuffer+totalmac
  12.  
  13. by pushing macrobuffer+totalmac as the first parameter to the
  14. function; however, the value of totalmac has changed so that the
  15. macronames[nmacros] is no longer equal to macrobuffer+totalmac.
  16.  
  17. #include <stdio.h>
  18. #include <string.h>
  19.  
  20. #define MACROBUFFERSIZE 800
  21. #define MAXMACROS 10
  22.  
  23. int macfileh,nrmacros=0;
  24. char macrobuffer[MACROBUFFERSIZE],*macronames[MAXMACROS];
  25. void openfiles()
  26. {
  27. char line[128];
  28. int totalmac;
  29. char *macropointer =macrobuffer;
  30. macropointer=macrobuffer+totalmac;
  31. macronames[nrmacros]=macropointer;
  32. totalmac += 1;
  33. if(totalmac<=MACROBUFFERSIZE)
  34. strcpy(macronames[nrmacros],line); /* does not work*/
  35. }
  36.  
  37. Response:
  38.    Microsoft has confirmed this to be a problem in Version 5.10
  39. of the C compiler.
  40.    You can work around the problem by calling the function strcpy with
  41. the variable macropointer instead of the variable
  42. macronames[nrmacros].
  43.    Microsoft is researching this problem and will post new information
  44. as it becomes available.
  45.  
  46. Keywords:  buglist5.10
  47. Updated  88/07/21 03:19
  48.